]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspaceThumbnail: unify restack handling
authorCosimo Cecchi <cosimoc@gnome.org>
Thu, 13 Dec 2012 16:00:30 +0000 (11:00 -0500)
committerCosimo Cecchi <cosimoc@gnome.org>
Mon, 17 Dec 2012 12:24:25 +0000 (13:24 +0100)
Both WorkspacesDisplay and ThumbnailsBox need to know when windows have been
restacked. Instead of each tracking changes on their own or trying to call
each other, have the overview keep track and do the calculations, emitting
a signal with the result.

https://bugzilla.gnome.org/show_bug.cgi?id=690175

js/ui/overview.js
js/ui/workspaceThumbnail.js
js/ui/workspacesView.js

index 5bb8fa1d25127c5aeb956ee793bc567013f15216..84cd48c6cf848014748ef278eee7343ec61cc78b 100644 (file)
@@ -174,6 +174,8 @@ const Overview = new Lang.Class({
         Main.xdndHandler.connect('drag-begin', Lang.bind(this, this._onDragBegin));
         Main.xdndHandler.connect('drag-end', Lang.bind(this, this._onDragEnd));
 
+        global.screen.connect('restacked', Lang.bind(this, this._onRestacked));
+
         this._windowSwitchTimeoutId = 0;
         this._windowSwitchTimestamp = 0;
         this._lastActiveWorkspaceIndex = -1;
@@ -383,6 +385,18 @@ const Overview = new Lang.Class({
         this._coverPane.set_size(primary.width, contentHeight);
     },
 
+    _onRestacked: function() {
+        let stack = global.get_window_actors();
+        let stackIndices = {};
+
+        for (let i = 0; i < stack.length; i++) {
+            // Use the stable sequence for an integer to use as a hash key
+            stackIndices[stack[i].get_meta_window().get_stable_sequence()] = i;
+        }
+
+        this.emit('windows-restacked', stackIndices);
+    },
+
     //// Public methods ////
 
     beginItemDrag: function(source) {
index b381dab4343678cd11b8a2567c9af80864d43fb4..fd68ce583ec2dcbc66d9fc398663e3971fc36292 100644 (file)
@@ -745,6 +745,9 @@ const ThumbnailsBox = new Lang.Class({
         this._nWorkspacesNotifyId =
             global.screen.connect('notify::n-workspaces',
                                   Lang.bind(this, this._workspacesChanged));
+        this._syncStackingId =
+            Main.overview.connect('windows-restacked',
+                                  Lang.bind(this, this._syncStacking));
 
         this._targetScale = 0;
         this._scale = 0;
@@ -780,6 +783,11 @@ const ThumbnailsBox = new Lang.Class({
             this._nWorkspacesNotifyId = 0;
         }
 
+        if (this._syncStackingId > 0) {
+            Main.overview.disconnect(this._syncStackingId);
+            this._syncStackingId = 0;
+        }
+
         for (let w = 0; w < this._thumbnails.length; w++)
             this._thumbnails[w].destroy();
         this._thumbnails = [];
@@ -854,7 +862,7 @@ const ThumbnailsBox = new Lang.Class({
         this._queueUpdateStates();
     },
 
-    syncStacking: function(stackIndices) {
+    _syncStacking: function(overview, stackIndices) {
         for (let i = 0; i < this._thumbnails.length; i++)
             this._thumbnails[i].syncStacking(stackIndices);
     },
index 5e66c2133be00ab3845728a7cdbf0ced01f42ef2..4d22f352f9b77b33853a03fbefb4dbc04b767056 100644 (file)
@@ -577,7 +577,7 @@ const WorkspacesDisplay = new Lang.Class({
         this._updateWorkspacesViews();
 
         this._restackedNotifyId =
-            global.screen.connect('restacked',
+            Main.overview.connect('windows-restacked',
                                   Lang.bind(this, this._onRestacked));
 
         if (this._itemDragBeginId == 0)
@@ -598,8 +598,6 @@ const WorkspacesDisplay = new Lang.Class({
         if (this._windowDragEndId == 0)
             this._windowDragEndId = Main.overview.connect('window-drag-end',
                                                           Lang.bind(this, this._dragEnd));
-
-        this._onRestacked();
     },
 
     zoomFromOverview: function() {
@@ -615,7 +613,7 @@ const WorkspacesDisplay = new Lang.Class({
             this.zoomFraction = 0;
 
         if (this._restackedNotifyId > 0){
-            global.screen.disconnect(this._restackedNotifyId);
+            Main.overview.disconnect(this._restackedNotifyId);
             this._restackedNotifyId = 0;
         }
         if (this._itemDragBeginId > 0) {
@@ -877,19 +875,9 @@ const WorkspacesDisplay = new Lang.Class({
         }
     },
 
-    _onRestacked: function() {
-        let stack = global.get_window_actors();
-        let stackIndices = {};
-
-        for (let i = 0; i < stack.length; i++) {
-            // Use the stable sequence for an integer to use as a hash key
-            stackIndices[stack[i].get_meta_window().get_stable_sequence()] = i;
-        }
-
+    _onRestacked: function(overview, stackIndices) {
         for (let i = 0; i < this._workspacesViews.length; i++)
             this._workspacesViews[i].syncStacking(stackIndices);
-
-        this._thumbnailsBox.syncStacking(stackIndices);
     },
 
     _workspacesChanged: function() {